﻿Imports System.Text
Imports System.Security.Cryptography

Module Encryption

    Public Function EncryptPassword(ByVal plainTextPassword As String) As String
        Dim sha As New SHA1Managed
        Dim encoder As New ASCIIEncoding
        Dim bytes As Byte() = encoder.GetBytes(plainTextPassword)
        Dim encryptedBytes As Byte() = sha.ComputeHash(bytes)

        Dim builder As New StringBuilder
        Dim lth As Integer = encryptedBytes.Length
        For lp As Integer = 0 To lth - 1
            builder.Append(String.Format("{0,2:x}", encryptedBytes(lp)).Replace(" ", "0"))
        Next
        Return builder.ToString
    End Function
End Module
